{% extends "base.html" %}

{% block main %}

{% block action %}
<form action="/info/add_info/" method="POST">
{% endblock %}

    {% csrf_token %}
    <span>标题</span>: {{form.title}} {{form.title.errors}}<br/>
    {% for f in fields %}
        {% if f.type == "string" %}
        <span>{{f.tag}}</span>:<input type="text" name="{{f.name}}" size="{{f.maxlen}}" value="{{f.value}}"/> 
        {{f.error}}<br/> 
        {% endif %}

        {% if f.type == "uint" or  f.type == "int" %}
        <span>{{f.tag}}</span>:<input type="text" name="{{f.name}}" value="{{f.value}}"/> {{f.error}}<br/> 
        {% endif %}

        {% if f.type == "radio" %}
        <span>{{f.tag}}</span>:
        {% for c in f.choices %} 
        <input type="radio" name="{{f.name}}" value="{{c.value}}" {% if c.value == f.value %}checked {% endif %}/> {{c.tag}}
        {% endfor %}
        {{f.error}}
        {% endif %}

        {% if f.type == "select" %}
        <br/>
        <span>{{f.tag}}</span>:
        <select name="{{f.name}}">
            {% for s in f.selects %}
            <option value="{{s.value}}" {% if f.value == s.value %}selected{% endif %}>{{s.tag}}</option>
            {% endfor %}
        </select>
        
        {{f.error}}
        {% endif %}

    {% endfor %}
    <br/>
    {{form.content.errors}}
    <span>内容</span>: {{form.content}}<br/>

    {% block infoex %}
    <input type="hidden" name="typeid" value="{{infotype.id}}"/>
    <input type="submit" value="AddInfo"/>
    {% endblock %}

</form>

{% endblock %}
